package com.mdlib.helper.api.service;

import com.mdlib.helper.model.BaseResult;
import com.mdlib.helper.model.entity.AddressEntity;
import com.mdlib.helper.model.entity.AgecyType;
import com.mdlib.helper.model.entity.AppInitEntity;
import com.mdlib.helper.model.entity.BalanceEntity;
import com.mdlib.helper.model.entity.BannerEntity;
import com.mdlib.helper.model.entity.BuyEntity;
import com.mdlib.helper.model.entity.CityEntity;
import com.mdlib.helper.model.entity.CommissionEntity;
import com.mdlib.helper.model.entity.IndexService;
import com.mdlib.helper.model.entity.MessageEntity;
import com.mdlib.helper.model.entity.MoneyEntity;
import com.mdlib.helper.model.entity.MoneyRelateEneity;
import com.mdlib.helper.model.entity.NearRunEntity;
import com.mdlib.helper.model.entity.OrderDetailsInfo;
import com.mdlib.helper.model.entity.OrderEntity;
import com.mdlib.helper.model.entity.OrderIdInfo;
import com.mdlib.helper.model.entity.OrderMoney;
import com.mdlib.helper.model.entity.ProblemEntity;
import com.mdlib.helper.model.entity.RechargeEntity;
import com.mdlib.helper.model.entity.RunInfo;
import com.mdlib.helper.model.entity.RunStatusEntity;
import com.mdlib.helper.model.entity.RunSystemMessage;
import com.mdlib.helper.model.entity.ServiceEntity;
import com.mdlib.helper.model.entity.ServiceMoney;
import com.mdlib.helper.model.entity.ServiceStartInfo;
import com.mdlib.helper.model.entity.ShareEntity;
import com.mdlib.helper.model.entity.StatusEntity;
import com.mdlib.helper.model.entity.UnReadMessage;
import com.mdlib.helper.model.entity.UpdateInfo;
import com.mdlib.helper.model.entity.UserEntity;
import com.mdlib.helper.model.entity.VoucherEntity;

import java.util.ArrayList;

import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.POST;
import rx.Observable;

/**
 * Created by librabin on 16/11/15.
 */

public interface UserApi {

    /**
     * 登录后初始化
     *
     * @return
     */
    @POST("system/init")
    Observable<BaseResult<AppInitEntity>> getSystemInit();

    @FormUrlEncoded
    @POST("system/set_run_location")
    Observable<BaseResult>  sendTude(@Field("lat") String latitude,
                                     @Field("long") String longitude);

    /**
     * 退出登录
     *
     * @return
     */
    @POST("user/logout")
    Observable<BaseResult> loginout();

    /**
     * 自动更新
     *
     * @param origin
     * @return
     */
    @FormUrlEncoded
    @POST("version/get_version")
    Observable<BaseResult<UpdateInfo>> getVersion(@Field("origin") String origin);

    /**
     * 开通城市
     *
     * @return
     */
    @POST("location/get_city")
    Observable<BaseResult<ArrayList<CityEntity>>> getCity();

    /**
     * 搜索城市
     *
     * @return
     */
    @FormUrlEncoded
    @POST("location/search_city")
    Observable<BaseResult<ArrayList<CityEntity>>> searchCity(@Field("pid") String pid);

    /**
     * 用户反馈
     *
     * @param fastContent
     * @param content
     * @return
     */
    @FormUrlEncoded
    @POST("user/feedback")
    Observable<BaseResult> sendFeedback(@Field("fast_content") String fastContent,
                                        @Field("content") String content);

    /**
     * 服务协议
     *
     * @return
     */
    @POST("article/agreement")
    Observable<BaseResult<ArrayList<ServiceEntity>>> getService();

    /**
     * Banner轮播图
     *
     * @param role
     * @param platform
     * @return
     */
    @FormUrlEncoded
    @POST("accept/get_banner")
    Observable<BaseResult<ArrayList<BannerEntity>>> getBanner(@Field("role") String role,
                                                              @Field("platform") String platform);

    //派单

    /**
     * 获取一键服务
     *
     * @return
     */
    @POST("service/index")
    Observable<BaseResult<IndexService>> getIndexService();

    /**
     * 获取代办类型
     *
     * @return
     */
    @POST("order/handle_type")
    Observable<BaseResult<ArrayList<AgecyType>>> getAgecy();


    /**
     * 修改昵称
     *
     * @param newNickName
     * @return
     */
    @FormUrlEncoded
    @POST("send_center/modify_nick_name")
    Observable<BaseResult> modifyNickName(@Field("nick_name") String newNickName);

    /**
     * 修改密码
     *
     * @param password
     * @param newPassword
     * @param rePassword
     * @return
     */
    @FormUrlEncoded
    @POST("user_center/modify_password")
    Observable<BaseResult> modifyPasswrod(@Field("password") String password,
                                          @Field("new_password") String newPassword,
                                          @Field("re_password") String rePassword);

    /**
     * 修改性别
     *
     * @param password
     * @return
     */
    @FormUrlEncoded
    @POST("user_center/set_sex")
    Observable<BaseResult> setSex(@Field("sex") String password);

    /**
     * 修改头像
     *
     * @param imgId
     * @return
     */
    @FormUrlEncoded
    @POST("send_center/upload_face")
    Observable<BaseResult> uploadFace(@Field("img_id") String imgId);


    /**
     * 获取用户信息
     */
    @POST("user/get_user_info")
    Observable<BaseResult<UserEntity>> fetchUserInfo();

    /**
     * 获取余额
     *
     * @return
     */
    @POST("send_center/accountant")
    Observable<BaseResult<BalanceEntity>> getBalance();

    /**
     * 收支明细
     *
     * @param role
     * @param page
     * @return
     */
    @FormUrlEncoded
    @POST("user_center/account_detail")
    Observable<BaseResult<ArrayList<MoneyRelateEneity>>> getAccountDetails(@Field("role") String role,
                                                                           @Field("page") String page);

    /**
     * 提现明细
     *
     * @param page
     * @return
     */
    @FormUrlEncoded
    @POST("send_center/withdraws_detail")
    Observable<BaseResult<ArrayList<MoneyRelateEneity>>> getWithdrawsDetails(@Field("page") String page);

    /**
     * 充值
     *
     * @param money
     * @param payType
     * @param platform
     * @return
     */
    @FormUrlEncoded
    @POST("user_center/recharge")
    Observable<BaseResult<RechargeEntity>> recharge(@Field("money") String money,
                                                    @Field("pay_type") String payType,
                                                    @Field("platform") String platform);

    /**
     * 提现
     *
     * @param phone
     * @param code
     * @param nickName
     * @param money
     * @param accountName
     * @return
     */
    @FormUrlEncoded
    @POST("user_center/withdraws")
    Observable<BaseResult> applyWithdraws(@Field("phone") String phone,
                                          @Field("code") String code,
                                          @Field("nick_name") String nickName,
                                          @Field("money") String money,
                                          @Field("account_name") String accountName
    );

    /**
     * 获取常用地址
     *
     * @return
     */
    @POST("send_center/addr_list")
    Observable<BaseResult<ArrayList<AddressEntity>>> getAddressList();

    /**
     * 添加或修改地址
     *
     * @param id
     * @param name
     * @param address
     * @param phone
     * @param type
     * @return
     */
    @FormUrlEncoded
    @POST("send_center/add_addr")
    Observable<BaseResult> updateAddress(@Field("id") String id,
                                         @Field("name") String name,
                                         @Field("address") String address,
                                         @Field("phone") String phone,
                                         @Field("type") String type);

    /**
     * 删除地址
     *
     * @param id
     * @return
     */
    @FormUrlEncoded
    @POST("send_center/del_addr")
    Observable<BaseResult> deteleAddrss(@Field("id") String id);

    /**
     * 获取常见问题
     *
     * @return
     */
    @POST("article/questions")
    Observable<BaseResult<ArrayList<ProblemEntity>>> getProblem();

    /**
     * 获取发单人消息
     *
     * @param page
     * @return
     */
    @FormUrlEncoded
    @POST("send_center/message")
    Observable<BaseResult<ArrayList<MessageEntity>>> getSendMessage(@Field("page") String page);

    /**
     * 我的购买
     *
     * @param page
     * @param type
     * @return
     */
    @FormUrlEncoded
    @POST("send_center/my_buy_list")
    Observable<BaseResult<ArrayList<BuyEntity>>> getSendMyBuy(@Field("page") String page,
                                                              @Field("type") String type);

    /**
     * 未使用代金券
     *
     * @param page
     * @return
     */
    @FormUrlEncoded
    @POST("send_center/unused_coupon")
    Observable<BaseResult<ArrayList<VoucherEntity>>> getUnusedVoucher(@Field("page") String page);

    /**
     * 已使用和过期代金券
     *
     * @param page
     * @return
     */
    @FormUrlEncoded
    @POST("send_center/disabled_coupon")
    Observable<BaseResult<ArrayList<VoucherEntity>>> getDisabledVoucher(@Field("page") String page,
                                                                        @Field("type") String type);


    /**
     * 附近的订单
     *
     * @param lat
     * @param longs
     * @param page
     * @return
     */
    @FormUrlEncoded
    @POST("order/nearby_order")
    Observable<BaseResult<ArrayList<OrderEntity>>> getSendVicinityOrder(@Field("lat") String lat,
                                                                        @Field("long") String longs,
                                                                        @Field("page") String page);

    /**
     * 附近的跑客
     *
     * @param lat
     * @param longs
     * @param page
     * @return
     */
    @FormUrlEncoded
    @POST("order/near_run")
    Observable<BaseResult<NearRunEntity>> getSendVicinityRun(@Field("lat") String lat,
                                                             @Field("long") String longs,
                                                             @Field("page") String page);

    /**
     * 获取进行中的订单
     *
     * @param page
     * @return
     */
    @FormUrlEncoded
    @POST("order/progress_order")
    Observable<BaseResult<ArrayList<OrderEntity>>> getOngoingOrder(@Field("page") String page);

    /**
     * 获取历史订单
     *
     * @param page
     * @return
     */
    @FormUrlEncoded
    @POST("order/history_order")
    Observable<BaseResult<ArrayList<OrderEntity>>> getHistoryOrder(@Field("page") String page);

    /**
     * 上传图片
     *
     * @param file
     * @param ext
     * @param type
     * @return
     */
//    @Multipart
//    @POST("Upload/up")
//    Observable<BaseResult<ArrayList<UpImage>>> uploadImage(@Part MultipartBody.Part file, @Part("ext") RequestBody ext, @Part("type") RequestBody type);

    /**
     * 申请跑男
     *
     * @param name
     * @param identity
     * @param urgentPhone
     * @param phone
     * @param head
     * @param take
     * @param face
     * @param back
     * @return
     */
    @FormUrlEncoded
    @POST("send_center/apply_for_run")
    Observable<BaseResult> applyRun(@Field("name") String name,
                                    @Field("identity") String identity,
                                    @Field("urgent_phone") String urgentPhone,
                                    @Field("phone") String phone,
                                    @Field("head_pic") String head,
                                    @Field("take_card") String take,
                                    @Field("face_card") String face,
                                    @Field("back_card") String back);

    /**
     * 获取跑男申请状态
     *
     * @return
     */
    @POST("send_center/examine")
    Observable<BaseResult<RunStatusEntity>> getRunStatus();

    /**
     * 获取分享信息
     *
     * @return
     */
    @POST("send_center/share")
    Observable<BaseResult<ShareEntity>> getShareInfo();

    /**
     * 分享成功之后发送
     *
     * @return
     */
    @POST("send_center/share_success")
    Observable<BaseResult> shareSuccess();

    /**
     * 代买
     *
     * @param remark
     * @param postAddr
     * @param getAddr
     * @param hopeTime
     * @param getPhone
     * @param platform
     * @param serviceMoney
     * @param busType
     * @param lat
     * @param length
     * @return
     */
    @FormUrlEncoded
    @POST("order/confirm_order")
    Observable<BaseResult<OrderIdInfo>> sendMinnetoka(@Field("remark") String remark,
                                                      @Field("post_addr") String postAddr,
                                                      @Field("get_addr") String getAddr,
                                                      @Field("hope_time") String hopeTime,
                                                      @Field("get_phone") String getPhone,
                                                      @Field("platform") String platform,
                                                      @Field("service_money") String serviceMoney,
                                                      @Field("bus_type") String busType,
                                                      @Field("pic_id") String picId,
                                                      @Field("lat") String lat,
                                                      @Field("long") String length,
                                                      @Field("coupon_id") String couponId
    );

    /**
     * 代送取
     *
     * @param remark
     * @param postAddr
     * @param getAddr
     * @param hopeTime
     * @param getPhone
     * @param platform
     * @param serviceMoney
     * @param busType
     * @param lat
     * @param longs
     * @param picId
     * @param couponId
     * @param postPhone
     * @param postLat
     * @param postLong
     * @param getLat
     * @param getLong
     * @return
     */
    @FormUrlEncoded
    @POST("order/confirm_order")
    Observable<BaseResult<OrderIdInfo>> sendTake(@Field("remark") String remark,
                                                 @Field("post_addr") String postAddr,
                                                 @Field("get_addr") String getAddr,
                                                 @Field("hope_time") String hopeTime,
                                                 @Field("get_phone") String getPhone,
                                                 @Field("platform") String platform,
                                                 @Field("service_money") String serviceMoney,
                                                 @Field("bus_type") String busType,
                                                 @Field("lat") String lat,
                                                 @Field("long") String longs,
                                                 @Field("pic_id") String picId,
                                                 @Field("coupon_id") String couponId,
                                                 @Field("post_phone") String postPhone,
                                                 @Field("post_lat") String postLat,
                                                 @Field("post_long") String postLong,
                                                 @Field("get_lat") String getLat,
                                                 @Field("get_long") String getLong
    );

    /**
     * 代办
     *
     * @param remark
     * @param hopeTime
     * @param getAddr
     * @param serviceMoney
     * @param lat
     * @param longs
     * @param handleType
     * @param busType
     * @param platform
     * @param getPhone
     * @param couponId
     * @return
     */
    @FormUrlEncoded
    @POST("order/confirm_order")
    Observable<BaseResult<OrderIdInfo>> sendAgency(@Field("remark") String remark,
                                                   @Field("hope_time") String hopeTime,
                                                   @Field("get_addr") String getAddr,
                                                   @Field("service_money") String serviceMoney,
                                                   @Field("lat") String lat,
                                                   @Field("long") String longs,
                                                   @Field("handle_type") String handleType,
                                                   @Field("bus_type") String busType,
                                                   @Field("platform") String platform,
                                                   @Field("get_phone") String getPhone,
                                                   @Field("coupon_id") String couponId);


    /**
     * 代送取 服务费
     *
     * @param lat
     * @param longs
     * @param lat1
     * @param long1
     * @return
     */
    @FormUrlEncoded
    @POST("order/calculate_money")
    Observable<BaseResult<ServiceMoney>> getTakeServiceMoney(@Field("lat") String lat,
                                                             @Field("long") String longs,
                                                             @Field("lat1") String lat1,
                                                             @Field("long1") String long1);

    /**
     * 支付订单
     *
     * @param orderId
     * @param payType
     * @return
     */
    @FormUrlEncoded
    @POST("order/pay_order")
    Observable<BaseResult<RechargeEntity>> payOrder(@Field("id") String orderId,
                                                    @Field("pay_type") String payType);

    /**
     * 获取订单信息
     *
     * @param busId
     * @return
     */
    @FormUrlEncoded
    @POST("order/get_order_info")
    Observable<BaseResult<OrderMoney>> getOrderMoney(@Field("bus_id") String busId);

    /**
     * 关闭订单
     *
     * @param busId
     * @return
     */
    @FormUrlEncoded
    @POST("order/close_order")
    Observable<BaseResult> closeOrder(@Field("bus_id") String busId);

    /**
     * 取消订单
     *
     * @param busId
     * @return
     */
    @FormUrlEncoded
    @POST("order/cancel_order")
    Observable<BaseResult> cancelOrder(@Field("bus_id") String busId);

    /**
     * 订单详情
     *
     * @param busId
     * @param role
     * @return
     */
    @FormUrlEncoded
    @POST("order/order_detail")
    Observable<BaseResult<OrderEntity>> getOrderDetaile(@Field("bus_id") String busId,
                                                             @Field("role") String role
    );

    /**
     * 增加服务费
     *
     * @param model
     * @param busId
     * @param money
     * @param platform
     * @return
     */
    @FormUrlEncoded
    @POST("order/add_service_money")
    Observable<BaseResult<RechargeEntity>> addServiceMoney(@Field("pay_type") String model,
                                                           @Field("bus_id") String busId,
                                                           @Field("money") String money,
                                                           @Field("platform") String platform);

    /**
     * 商品付款
     *
     * @param busId
     * @param price
     * @param payType
     * @param platform
     * @return
     */
    @FormUrlEncoded
    @POST("order/pay_goods")
    Observable<BaseResult<RechargeEntity>> payGoods(@Field("bus_id") String busId,
                                                    @Field("price") String price,
                                                    @Field("pay_type") String payType,
                                                    @Field("platform") String platform
    );

    /**
     * 获取佣金
     *
     * @param money
     * @return
     */
    @FormUrlEncoded
    @POST("order/get_commission")
    Observable<BaseResult<CommissionEntity>> getCommission(@Field("money") String money);


    /**
     * 获取用户代金券(下单选择用)
     *
     * @return
     */
    @POST("order/get_coupon")
    Observable<BaseResult<ArrayList<VoucherEntity>>> getMyVoucher();


    /**
     * 获取初始服务费
     *
     * @return
     */
    @POST("order/get_service_money")
    Observable<BaseResult<ServiceMoney>> getServiceMoney();

    /**
     * 确认订单
     *
     * @param busId
     * @return
     */
    @FormUrlEncoded
    @POST("order/complete_order")
    Observable<BaseResult> completeOrder(@Field("bus_id") String busId);

    /**
     * 设置线下支付
     *
     * @param bus_id
     * @param status
     * @return
     */
    @FormUrlEncoded
    @POST("order/set_offline_pay")
    Observable<BaseResult> setOfflinePay(@Field("bus_id") String bus_id,
                                         @Field("status") String status);


    /**
     * 申请异常
     *
     * @param busId
     * @param userId
     * @param runId
     * @param applyRole
     * @param reason
     * @return
     */
    @FormUrlEncoded
    @POST("order/unusual")
    Observable<BaseResult> unusual(@Field("order_id") String busId,
                                   @Field("user_id") String userId,
                                   @Field("pao_id") String runId,
                                   @Field("apply_role") String applyRole,
                                   @Field("reason") String reason);


    /**
     * 评价跑客
     *
     * @param busId
     * @param star
     * @param type
     * @return
     */
    @FormUrlEncoded
    @POST("order/evaluate_run")
    Observable<BaseResult<MoneyEntity>> evaluateRun(@Field("bus_id") String busId,
                                                    @Field("star") String star,
                                                    @Field("type") String type);


//    跑客

    /**
     * 系统消息
     *
     * @return
     */
    @POST("system/get_msg")
    Observable<BaseResult<RunSystemMessage>> getSystem();


    /**
     * 我的余额主页
     *
     * @return
     */
    @POST("run_center/accountant")
    Observable<BaseResult<RunInfo>> getRunInfo();


    /**
     * 附近的订单
     *
     * @param lat
     * @param longs
     * @param type
     * @return
     */
    @FormUrlEncoded
    @POST("accept/show_order")
    Observable<BaseResult<ArrayList<OrderEntity>>> getRunVicinityOrder(@Field("lat") String lat,
                                                                       @Field("long") String longs,
                                                                       @Field("type") String type);

    /**
     * 跑客接单状态设置
     *
     * @return
     */
    @FormUrlEncoded
    @POST("run_center/set_order_status")
    Observable<BaseResult> setOrderRules(@Field("status") String status);

    /**
     * 获取关键字
     *
     * @return
     */
    @POST("run_center/get_keywords")
    Observable<BaseResult<ArrayList<String>>> getKeywords();

    /**
     * 获取最近的一个订单
     *
     * @param lat
     * @param longs
     * @return
     */
    @FormUrlEncoded
    @POST("accept/accept_order")
    Observable<BaseResult<OrderEntity>> getRecentOrder(@Field("lat") String lat,
                                                       @Field("long") String longs);

    /**
     * 抢单
     *
     * @param busId
     * @return
     */
    @FormUrlEncoded
    @POST("accept/rush_order")
    Observable<BaseResult> rusnOrder(@Field("bus_id") String busId);

    /**
     * 进行中订单
     *
     * @param page
     * @return
     */
    @FormUrlEncoded
    @POST("accept/progress_order")
    Observable<BaseResult<ArrayList<OrderEntity>>> getRushOngOrder(@Field("page") String page);

    /**
     * 历史订单
     *
     * @param page
     * @return
     */
    @FormUrlEncoded
    @POST("accept/history_order")
    Observable<BaseResult<ArrayList<OrderEntity>>> getRushHistoryOrder(@Field("page") String page);

    /**
     * 已购买/已取货/已送达
     *
     * @param busId
     * @return
     */
    @FormUrlEncoded
    @POST("accept/done")
    Observable<BaseResult> setDoneOrder(@Field("bus_id") String busId);

    /**
     * 跑客确认送达
     *
     * @param busId
     * @return
     */
    @FormUrlEncoded
    @POST("accept/complete")
    Observable<BaseResult> setCompleteOrder(@Field("bus_id") String busId);

    /**
     * 星级评价列表
     *
     * @param page
     * @return
     */
    @FormUrlEncoded
    @POST("run_center/star")
    Observable<BaseResult<ArrayList<ServiceStartInfo>>> getServiceStart(@Field("page") String page);

    /**
     * 推广注册
     *
     * @return
     */
    @POST("run_center/register_share")
    Observable<BaseResult<ShareEntity>> getRushShareInfo();


    /**
     * 设置新消息通知
     *
     * @param status
     * @return
     */
    @FormUrlEncoded
    @POST("accept/set_notice")
    Observable<BaseResult> setNotice(@Field("status") String status);


    /**
     * 获取接单状态
     *
     * @return
     */
    @POST("accept/get_status")
    Observable<BaseResult<StatusEntity>> getRunStatues();

    /**
     * 精准接单
     *
     * @return
     */
    @FormUrlEncoded
    @POST("user_center/accurate_order")
    Observable<BaseResult> setAccurate(@Field("keywords") String key,
                                       @Field("type") String type);

    /**
     * 跑客消息列表
     *
     * @param page
     * @return
     */
    @FormUrlEncoded
    @POST("run_center/message")
    Observable<BaseResult<ArrayList<MessageEntity>>> getRushMessageInfo(@Field("page") String page);


    /**
     * 提现
     *
     * @param phone
     * @param code
     * @param nick_name
     * @param money
     * @param name
     * @return
     */
    @FormUrlEncoded
    @POST("run_center/run_withdraws")
    Observable<BaseResult> rushApplyWithdraws(@Field("phone") String phone,
                                              @Field("code") String code,
                                              @Field("nick_name") String nick_name,
                                              @Field("money") String money,
                                              @Field("account_name") String name
    );

    /**
     * 跑客设置立即购买
     *
     * @param bus_id
     * @param status
     * @return
     */
    @FormUrlEncoded
    @POST("order/set_immediately_buy")
    Observable<BaseResult> setImmediatelyBuy(@Field("bus_id") String bus_id,
                                             @Field("status") String status);

    /**
     * 获取未读消息数量
     */
    @POST("order/get_unread_count")
    Observable<BaseResult<UnReadMessage>> getUnreadMessage();

    /**
     * 设置未读消息
     */
    @POST("order/set_read")
    Observable<BaseResult> setUnreadMessage();


}
